<!DOCTYPE html>
<html lang="en">
<head th:include="/header:: header"></head>
<body class="login-body">
	<div class="container">
		<form class="form-signin" th:action="@{/login}" method="post"
			id="loginForm">
			<div class="form-signin-heading text-center">
				<h1 class="sign-title">登录</h1>
				<img src="../components/AdminEx/images/login-logo.png" alt="" />
			</div>
			<div th:if="${param.error}">
				<div class="alert alert-warning">
					<a href="#" class="close" data-dismiss="alert"> &times; </a> <strong>警告！</strong>用户名或密码错误。
				</div>
			</div>
			<div th:if="${param.logout}">
				<div class="alert alert-warning">
					<a href="#" class="close" data-dismiss="alert"> &times; </a> <strong>警告！</strong>退出。
				</div>
			</div>
			<div class="login-wrap">
				<input type="text" class="form-control" placeholder="User ID"
					autofocus="autofocus" id="username" name="username" /> <input
					type="password" class="form-control" placeholder="Password"
					id="password" name="password" />

				<button class="btn btn-lg btn-login btn-block" type="submit"
					id="loginBtn">
					<i class="fa fa-check"></i>
				</button>
				<!-- 
				<hr />
				使用以下账号直接登录:<br />
				<div class="fa fa-github fa-2x" onclick="openWin('github')"></div>
				&nbsp;
				<div class="fa fa-wechat fa-2x"></div>
				&nbsp;
				<div class="fa fa-qq fa-2x"></div>
				&nbsp;
				<div class="fa fa-weibo fa-2x" onclick="openWin('weibo')"></div>
				&nbsp;
				<div>
					<fb:login-button scope="public_profile,email"
						onlogin="chekcFBLoginStatus();"></fb:login-button>
				</div>
                -->
			</div>
		</form>
	</div>
</body>
<script th:src="@{../modular/platform/login/login.js}"></script>
<script th:inline="javascript">
	function openWin(type) {
		var url;
		if (type == "github") {
			url = [[${github}]];
		}
		else if (type == "weibo") {
			
           url =  [[${weibo}]];
		}

		window.open(url);
	}
	
	//---- facebook
	window.fbAsyncInit = function() {
		FB.init({
			appId : '125559064784632', // 这里需要改成15位你创建的Facebook应用编号
			cookie : true,
			xfbml : true,
			version : 'v2.8'
		});
		FB.AppEvents.logPageView();
	};

	(function(d, s, id) {
		var js, fjs = d.getElementsByTagName(s)[0];
		if (d.getElementById(id)) {
			return;
		}
		js = d.createElement(s);
		js.id = id;
		js.src = "//connect.facebook.net/en_US/sdk.js";
		fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));

	// 使用官方按钮登录完成后的回调函数
	function chekcFBLoginStatus() {
		FB.getLoginStatus(function(response) {
			if (response.status === 'connected') {
				FB.api('/me?fields=id,email,first_name,last_name,gender', function(response) {
				    var fbu = JSON.stringify(response);
				    var fbuId = JSON.parse(fbu).id;
				    console.log(fbu);
				    console.log(fbuId);
				  //<![CDATA[
                     var fbuurl =   "/oauth2/afterBind?type=facebook&id=" +fbuId;
				  //]]>
				    console.log(fbuurl);
				    window.open(fbuurl);
				    
				    
				});
			} else {
				alert('登录失败');
			}
		});
	}
	
</script>
<div th:include="/footer:: footer"></div>
</html>